package com.py.credit.entity.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.py.credit.entity.common.OptionalColumn;

/**
 * 资源目录列表显示列枚举
 * 
 * @author dd
 *
 */
public enum ResourceTableFieldsEnum {
	
//	SJLB("sjlb", "数据类别", "varchar", "input", true, false, new HashMap<String, String>(), false, false),

	RESOURCE_ID("resource_id", "信息资源标识符", "varchar", "input", true, false, new HashMap<String, String>(), false, false),

	RESOURCE_TITLE("resource_title", "信息资源名称", "varchar", "input", true, true, new HashMap<String, String>(), true,
			true),

	SHARING_TYPE("sharing_type", "公开属性", "varchar", "select", true, false, new HashMap<String, String>() {

		private static final long serialVersionUID = 1L;

		{
			put("P", "社会公开");
			put("S", "政务共享");
			put("A", "授权查询");

		}
	}, true, true), UPDATE_FRENQUENCY("update_frequency", "更新频率", "varchar", "select", true, false,
			new HashMap<String, String>() {

				private static final long serialVersionUID = 1L;

				{
					put("S", "实时");
					put("D", "每日");
					put("W", "每周");
					put("M", "每月");
					put("Q", "每季度");
					put("Y", "每年");

				}
			}, true, true),

	MANAGEMENT_STYLE("management_style", "管理方式", "varchar", "select", true, false, new HashMap<String, String>() {

		private static final long serialVersionUID = 1L;

		{
			put("M", "手动");
			put("A", "计算机处理");

		}
	}, true, true),

	MAINTAINER("maintainer", "维护人", "varchar", "input", true, false, new HashMap<String, String>(), false, false),

	UPDATE_TIME("update_time", "维护时间", "timestamp", "", true, false, new HashMap<String, String>(), true,
			false), SUMMARY("summary", "信息资源摘要", "varchar", "textarea", false, false, new HashMap<String, String>(),
					false, false),

	RESOURCE_CATEGORY("resource_category", "信息资源分类", "varchar", "input", false, false, new HashMap<String, String>(),
			false, false),

	ONLINE("online", "在线资源链接地址", "varchar", "input", false, false, new HashMap<String, String>(), false,
			false), DATE_OF_PUBLICATION("date_of_publication", "发布日期", "timestamp", "", false, false,
					new HashMap<String, String>(), false, false), SERVICE_URL("service_url", "服务地址", "varchar", "input",
							false, false, new HashMap<String, String>(), false, false), SERVICE_TYPE("service_type",
									"服务类型", "varchar", "select", false, false, new HashMap<String, String>() {

										/**
										 * 
										 */
										private static final long serialVersionUID = 1L;

										{
											put("I", "接口");
											put("D", "目录");

										}
									}, true, false), ORGANISATION_NAME("organisation_name", "资源提供单位", "varchar",
											"input", false, false, new HashMap<String, String>(), false,
											false), PROVIDER_ADDRESS("provider_address", "资源提供方地址", "varchar", "input",
													false, false, new HashMap<String, String>(), false,
													false), PROVIDER_CONTACT("provider_contact", "资源提供联系人", "varchar",
															"input", false, false, new HashMap<String, String>(), false,
															false), METADATA_CONTACT("metadata_contact", "元数据维护方",
																	"varchar", "input", false, false,
																	new HashMap<String, String>(), false,
																	false), MAINTAINER_ADDRESS("maintainer_address",
																			"元数据维护方地址", "varchar", "input", false,
																			false, new HashMap<String, String>(), false,
																			false);

	private String colNameEN;
	private String colNameCN;
	private String type;
	private boolean defaultShow;
	private boolean advanceConditionShow;
	private String widget;
	private boolean fuzzy;
	private HashMap<String, String> widgetValue;
	private boolean searchIsShow;

	private ResourceTableFieldsEnum(String colNameEN, String colNameCN, String type, String widget, boolean defaultShow,
			boolean fuzzy, HashMap<String, String> widgetValue, boolean advanceConditionShow, boolean searchIsShow) {
		this.colNameEN = colNameEN;
		this.colNameCN = colNameCN;
		this.type = type;
		this.widget = widget;
		this.defaultShow = defaultShow;
		this.fuzzy = fuzzy;
		this.widgetValue = widgetValue;
		this.advanceConditionShow = advanceConditionShow;
		this.searchIsShow = searchIsShow;
	}

	public String getColNameEN() {
		return colNameEN;
	}

	public void setColNameEN(String colNameEN) {
		this.colNameEN = colNameEN;
	}

	public String getColNameCN() {
		return colNameCN;
	}

	public void setColNameCN(String colNameCN) {
		this.colNameCN = colNameCN;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public boolean isDefaultShow() {
		return defaultShow;
	}

	public void setDefaultShow(boolean defaultShow) {
		this.defaultShow = defaultShow;
	}

	public HashMap<String, String> getWidgetValue() {
		return widgetValue;
	}

	public void setWidgetValue(HashMap<String, String> widgetValue) {
		this.widgetValue = widgetValue;
	}

	public String getWidget() {
		return widget;
	}

	public void setWidget(String widget) {
		this.widget = widget;
	}

	public boolean isFuzzy() {
		return fuzzy;
	}

	public void setFuzzy(boolean fuzzy) {
		this.fuzzy = fuzzy;
	}

	public boolean isAdvanceConditionShow() {
		return advanceConditionShow;
	}

	public void setAdvanceConditionShow(boolean advanceConditionShow) {
		this.advanceConditionShow = advanceConditionShow;
	}

	public boolean isSearchIsShow() {
		return searchIsShow;
	}

	public void setSearchIsShow(boolean searchIsShow) {
		this.searchIsShow = searchIsShow;
	}

	public static List<OptionalColumn> getOptionalColumns() {

		List<OptionalColumn> OptionalColumns = new ArrayList<OptionalColumn>();

		ResourceTableFieldsEnum[] values = ResourceTableFieldsEnum.values();

		for (ResourceTableFieldsEnum value : values) {

			OptionalColumn optionalColumn = new OptionalColumn(value.getColNameEN(), value.getColNameCN(),
					value.getType(), value.isDefaultShow(), value.getWidget(), value.isFuzzy(), value.getWidgetValue(),
					value.isSearchIsShow());
			OptionalColumns.add(optionalColumn);

		}
		return OptionalColumns;

	}

	public static List<OptionalColumn> getAdvancedConditionColumns() {

		List<OptionalColumn> OptionalColumns = new ArrayList<OptionalColumn>();

		ResourceTableFieldsEnum[] values = ResourceTableFieldsEnum.values();

		for (ResourceTableFieldsEnum value : values) {

			if (value.isAdvanceConditionShow()) {

				OptionalColumn optionalColumn = new OptionalColumn(value.getColNameEN(), value.getColNameCN(),
						value.getType(), value.isDefaultShow(), value.getWidget(), value.isFuzzy(),
						value.getWidgetValue(), value.isSearchIsShow());
				OptionalColumns.add(optionalColumn);
			}

		}
		return OptionalColumns;

	}

	public static List<String> getDefaultShowColumnEN() {

		List<String> columns = new ArrayList<String>();

		ResourceTableFieldsEnum[] values = ResourceTableFieldsEnum.values();

		for (ResourceTableFieldsEnum value : values) {

			if (value.isDefaultShow()) {

				columns.add(value.getColNameEN());
			}

		}
		return columns;

	}

}
